<template>
	<div class="container">
		<el-breadcrumb separator-class="el-icon-arrow-right">
			<el-breadcrumb-item :to="{ path: '/Main' }"><b>首页</b></el-breadcrumb-item>
			<el-breadcrumb-item :to="{ path: '/Main/ThotelBrandType' }">主题管理</el-breadcrumb-item>
			<el-breadcrumb-item><b>新增品牌类型管理</b></el-breadcrumb-item>
		</el-breadcrumb>

		<el-form :model="ff" :rules="rules" ref="ff" label-width="100px" class="demo-ruleForm" style="margin-top: 15px;"
		 :inline=true >
			<el-form-item label="编号" prop="ttId" style="width: 500px;" v-if="false">
				<el-input v-model="ff.ttId" style="width: 300px;" readonly="readonly" :disabled="true"></el-input>
			</el-form-item>
			<el-form-item label="品牌类型名称" prop="ttName" style="width: 400px;" label-width="100px">
				<el-input v-model="ff.ttName" style="width: 300px;"></el-input>
			</el-form-item>
			
			
			
			
			<el-form-item style="width: 700px;margin-left: 300px;">
				<el-button type="primary" @click="save()">立即添加</el-button>
				<el-button @click="resetForm('ff')" style="margin-left: 100px;margin-top: 20px;">重置</el-button>
			</el-form-item>
		</el-form>

	</div>
</template>

<script>
	export default {
		data() {
			
			return {
				ff: {
					ttName: '',
					
					
				},
				rules: {
					ttName: [{
						required: true,
						message: '请输入品牌类型名称',
						trigger: 'blur'
					}],

					

					
				}
			};
		},
		methods: {
	
	save: function() {
		console.log("到这里面来了");
		this.$refs['ff'].validate((valid) => {
			if (valid) {
				//获取请求URL
				let url = this.axios.urls.SYS_SC_ADD;
				// console.log(this.ff);
				//发送ajax请求
				console.log("到这里面来了2222",this.ff);  
				
				this.axios.post(url, this.ff).then((response) => {
					console.log("111",response.data);
					let data = response.data;
					console.log("222",data);
					if (data.success) {
						this.$confirm('新增成功！是否继续添加?', '提示', {
							confirmButtonText: '确定',
							cancelButtonText: '取消',
							type: 'warning',
							center: true
						}).then(() => {
							this.ff.ttName = '';
							// this.ff.type = '';
							// this.ff.icon = '';
							
		
						}).catch(() => {})
						// this.$router.replace('/SalChanceList');
					} else {
						this.$message({
							message: "添加成功",
							type: 'success'
						});
					}
					this.$router.replace('/Main/ThotelBrandType');
				}).catch(err => {
					console.log(err);
				})
			} else {
				console.log('error submit!!');
				return false;
			}
		});
		
	},
			
			resetForm(formName) {
				this.$refs[formName].resetFields();
			},
			
		},
		created:function(){
			console.log(this.ff);
		}
	}
</script>

<style>
	.container {
		margin: 15px;
	}
</style>
